package _99Exercise;

public class Poker1 implements Comparable<Poker1> {
	int cardId;

	@Override
	public String toString() {
		if (cardId == 53)
			return "大鬼";
		if (cardId == 54)
			return "小鬼";
		int type = (cardId - 1) / 13 + 1;
		int n = (cardId - 1) % 13 + 1;
		String[] symbol = { "♥", "♠", "♣", "♦" };
		String[] nums = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };
		return symbol[type - 1] + nums[n - 1];
	}

	public Poker1() {
		super();
		// TODO Auto-generated constructor stub
	}

	public Poker1(int cardId) {
		super();
		this.cardId = cardId;
	}

	static Poker1 getCard() {
		Poker1 p = new Poker1();
		p.cardId = (int) (Math.random() * 54) + 1;
		return p;

	}

	@Override
	public int compareTo(Poker1 o) {
		// TODO Auto-generated method stub
		if (this.cardId < o.cardId) {
			return -1;
		} else if (this.cardId == o.cardId) {
			return 0;
		} else {
			return 1;
		}
	}

}
